package org.quasar.airNova.presentationLayer;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.ComboBoxModel;

public class AssociarIndividual extends JPanel {
	private Gui gui;
	private JComboBox clienteCB;
	private JComboBox paisComboBox;

	/**
	 * Create the panel.
	 */
	public AssociarIndividual(Gui gui) {
		this.setGui(gui);
		setLayout(new BorderLayout(0, 0));
		this.setSize(500, 350);
		JPanel panel = new JPanel();
		add(panel, BorderLayout.CENTER);
		panel.setLayout(null);

		JLabel lblNewLabel = new JLabel("Cliente");
		lblNewLabel.setBounds(40, 76, 151, 14);
		panel.add(lblNewLabel);

		JLabel lblNewLabel_2 = new JLabel("Pa\u00EDs");
		lblNewLabel_2.setBounds(40, 114, 126, 14);
		panel.add(lblNewLabel_2);

		JButton btnNewButton = new JButton("Submeter");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(clienteCB.getSelectedItem() != null && paisComboBox.getSelectedItem() != null)
				AirNova_Database.associarIndividualPais(
						(String) clienteCB.getSelectedItem(),
						(String) paisComboBox.getSelectedItem());
			}
		});
		btnNewButton.setBounds(44, 217, 98, 23);
		panel.add(btnNewButton);

		JButton btnNewButton_1 = new JButton("Cancelar");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getGui().getTabbedPane().removeTabAt(
						getGui().getTabbedPane().getSelectedIndex());
			}
		});
		btnNewButton_1.setBounds(152, 217, 89, 23);
		panel.add(btnNewButton_1);

		JLabel lblNewLabel_3 = new JLabel("Associar Individual a um pa\u00EDs");
		lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 17));
		lblNewLabel_3.setBounds(30, 24, 222, 32);
		panel.add(lblNewLabel_3);

		clienteCB = new JComboBox(Tools.getIndividuaisCodigos());
		clienteCB.setBounds(201, 73, 174, 20);
		panel.add(clienteCB);

		paisComboBox = new JComboBox(Tools.getPaisesName());
		paisComboBox.setBounds(201, 111, 174, 20);
		panel.add(paisComboBox);
	}

	public Gui getGui() {
		return gui;
	}

	public void setGui(Gui gui) {
		this.gui = gui;
	}
}